<template>
    <el-dialog
        title=""
        :visible.sync="dialogVisible"
        :width="width">
        <div class="dialog-content-wrapper">
            <div class="dialog-content-box">
                <h1>弹窗文字</h1>
                <p>{{JSON.stringify(info)}}</p>
            </div>
            <div slot="footer">
                <el-button @click="handleDialogCancel">取 消</el-button>
                <el-button type="primary" @click="handleDialogConfirm">确 定</el-button>
            </div>
        </div>
    </el-dialog>
</template>

<script>
export default {
    props:['isVisible', 'info'],
    data() {
        return {
            width: '700px'
        }
    },

    computed: {
        dialogVisible: {
            get() {
                return this.isVisible;
            },

            set(bool) {
                console.log('dialogVisible is changed, so init the dialog now', bool);
                this.$emit('flagsChange', bool, false)
            }
        }
    },

    methods: {
        handleDialogConfirm() {
            console.log('this is functino for confirm btn');
            // 注意，第一个参数是事件名，第二个参数是弹窗打开状态， 第三个参数是按钮状态（确认按钮：true； 取消按钮：false）；
            this.$emit('flagsChange', false, true);
        },
        handleDialogCancel() {
            console.log('this is function for cancel btn');
            this.$emit('flagsChange', false, false);
        }
    },
}
</script>